cnosole.log(document.cookie);
let user=encodeURIComponent('John Doe');
let retain=encodeURIComponent('Thu, 18 Dec 2043 12:00:00 GMT');
let path=encodeURIComponent('/');
// notice: only one item can be set at one time
document.cookie=`username=${user};
				expires=${retain};
				path=${path}`;
console.log(document.cookie);

function setCookie(name,value,time){
	let d=new Date();
	d.setTime(d.getTime()+(time*24*60*60*1000));
	document.cookie=`${name}=value;expires=${d};path=/`;
}

function getCookie(name){
	let cookies=document.cookie.split(';');
	for(cookie of cookies){
		if(cookie.startsWith(`${name}=`)){
			return cookie;
		}
	}
	return null;
}

function checkCookie(name){
	return getCookie(name)!==null;
}
